from data_factory.pms_user_info import PmsUserInfo


class RoleConfig:
    def __init__(self, username):
        # 主理人
        self.ADVISER = {
            "role": "adviser",
            "username": "",
            "adviserId": "",
            "pmsUserId": ""
        }
        # 审核员
        self.REVIEWER = {
            "role": "reviewer",
            "username": "",
            "pmsUserId": ""
        }
        # 交易员
        self.TRADER = {
            "role": "trader",
            "username": "",
            "pmsUserId": ""
        }
        # 平台管理员
        self.ADMIN = {
            "role": "admin",
            "username": "pms_admin@yingmi.cn"
        }
        self.set_adviser_username(username)
        self.set_reviewer_and_trader_username()
        self.set_adviser_adviser_id()
        self.set_pms_user_id()

    def set_adviser_username(self, new_username):
        self.ADVISER['username'] = new_username

    def set_reviewer_and_trader_username(self):
        [self.REVIEWER['username'], self.TRADER['username']] = PmsUserInfo.getReviewerAndTraderByAdviser(
            self.ADVISER['username'])

    def set_adviser_adviser_id(self):
        self.ADVISER['adviserId'] = PmsUserInfo.getAdviserIdByAdviserName(self.ADVISER['username'])

    def set_pms_user_id(self):
        self.ADVISER['pmsUserId'] = PmsUserInfo.getPmsUserIdByUserAccount(self.ADVISER['username'])
        self.REVIEWER['pmsUserId'] = PmsUserInfo.getPmsUserIdByUserAccount(self.REVIEWER['username'])
        self.TRADER['pmsUserId'] = PmsUserInfo.getPmsUserIdByUserAccount(self.TRADER['username'])


role_config = RoleConfig("pms1174@xxx.cn")
